
package Telas;

import Conexao.ConectaBD;
import com.itextpdf.text.BadElementException;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
import java.awt.Desktop;
import java.awt.Toolkit;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;


public class Tela_RegVendas extends javax.swing.JFrame {

    Connection conecta;
    PreparedStatement pst;
    ResultSet rs;

    DefaultListModel dlm = new DefaultListModel();
    
    public Tela_RegVendas() throws ClassNotFoundException {
        initComponents();
        setSize(1283, 653);
        setLocationRelativeTo(null);
        conecta = ConectaBD.conectabd();
        listarCliente();
        selecionaProduto();
        selecionaVendedor();
        Icon();
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    private void Icon(){
    
        setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("assistec_icon.png")));
        
    }    


//<----------------------------------------------------------------------------------------------------------------------------------------->
    public void listarCliente() {
        String sql = "Select *from cliente order by id Desc";
        try {
            pst = conecta.prepareStatement(sql);
            rs = pst.executeQuery();
            jt_cliente.setModel(DbUtils.resultSetToTableModel(rs));
        } catch (SQLException error) {
            JOptionPane.showMessageDialog(null, error);
        }
    }

//<----------------------------------------------------------------------------------------------------------------------------------------->
    public void registrarVenda() {
        
        
        String sql = "Insert into venda (Nome,Endereço,Numero,Telefone,Vendedor,DataVenda,DataPagamento,Numero_Parcelas,Valor_Parcelas,Numero_ParcelasPG,Forma_Pagamento,Pagamento,Total_Compra,Produtos) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        if(tf_nome.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo Nome é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(jf_telefone.getText().equals("(  )    -    ")){
        JOptionPane.showMessageDialog(null, "Campo Telefone é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(cb_vendedor.getSelectedItem().equals("VENDEDOR")){
        JOptionPane.showMessageDialog(null, "Campo Vendedor é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(jf_datav.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo Data é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(tf_quantidade.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo Quantidade é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(tf_valorunit.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo Valor é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(tf_totalproduto.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo Total Produto é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(tf_nparcelas.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo Nº Parcelas é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(jt_produtos.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Adicione ao menos um produto à lista", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(tf_valorparcela.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo Valor Parcela é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(tf_total.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo Total da Compra é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        
        try {
            pst = conecta.prepareStatement(sql);
            pst.setString(1, tf_nome.getText());
            pst.setString(2, tf_endereco.getText());
            pst.setString(3, tf_numero.getText());
            pst.setString(4, jf_telefone.getText());
            pst.setString(5, cb_vendedor.getSelectedItem().toString());
            pst.setString(6, jf_datav.getText());
            pst.setString(7, jf_datap.getText());
            pst.setString(8, tf_nparcelas.getText());
            pst.setString(9, tf_valorparcela.getText());
            pst.setString(10, tf_parcelaspg.getText());
            pst.setString(11, cb_formapgto.getSelectedItem().toString());
            pst.setString(12, cb_pagamento.getSelectedItem().toString());
            pst.setString(13, tf_total.getText());
            pst.setString(14, jt_produtos.getText());

            pst.execute();
            JOptionPane.showMessageDialog(null, "Venda Registrada com Sucesso!", "Venda Registrada com Sucesso", JOptionPane.INFORMATION_MESSAGE);
            listarCliente();
            Limpar();

        } catch (SQLException error) {
            JOptionPane.showMessageDialog(null, error);
        }
    }

//<----------------------------------------------------------------------------------------------------------------------------------------->
    public void pesquisarCliente() {
        String sql = "Select * from cliente where Nome like ?";

        try {
            pst = conecta.prepareStatement(sql);
            pst.setString(1, tf_pesquisar.getText() + "%");
            rs = pst.executeQuery();
            jt_cliente.setModel(DbUtils.resultSetToTableModel(rs));
        } catch (SQLException error) {
            JOptionPane.showMessageDialog(null, error);
        }
    }

//<----------------------------------------------------------------------------------------------------------------------------------------->
    public void mostraItens() throws ClassNotFoundException {

        int seleciona = jt_cliente.getSelectedRow();
        tf_id.setText(jt_cliente.getModel().getValueAt(seleciona, 0).toString());
        tf_nome.setText(jt_cliente.getModel().getValueAt(seleciona, 1).toString());
        tf_endereco.setText(jt_cliente.getModel().getValueAt(seleciona, 2).toString());
        tf_numero.setText(jt_cliente.getModel().getValueAt(seleciona, 3).toString());
        jf_telefone.setText(jt_cliente.getModel().getValueAt(seleciona, 8).toString());
    }

//<----------------------------------------------------------------------------------------------------------------------------------------->    
    private void selecionaProduto() {

        try {
                
            String sql = "select * from produto";
            pst = conecta.prepareStatement(sql);
            rs = pst.executeQuery();                
            while (rs.next()) {
                String NomeProduto = rs.getString("Produto_Serviço");
                cb_produto.addItem(NomeProduto);               
            }

        } catch (Exception e) {
        }

    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    
    private void selecionaVendedor() {

        try {
                
            String sql = "select * from funcionario";
            pst = conecta.prepareStatement(sql);
            rs = pst.executeQuery();                
            while (rs.next()) {
                String NomeProduto = rs.getString("Nome");
                cb_vendedor.addItem(NomeProduto);               
            }

        } catch (Exception e) {
        }

    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->
    
    public void PDF(String ID, String Nome, String Endereco, String Nº, String Telefone, String Vendedor, String DataVenda, String DataPagamento, String Produtos, String NParcelas, String ValorParcelas, String NParcelasPagas, String FormaPagamento, String Pagamento, String TotalCompra) throws BadElementException, IOException {

        Document documento = new Document(PageSize.A4, 72, 72, 72, 72);
        try {
            OutputStream outputStream = new FileOutputStream("venda.pdf");
            PdfWriter.getInstance(documento, outputStream);
            documento.open();//abre o arquivo

            Image imagem = Image.getInstance("assistec_cabeçalho.png");
            documento.add(imagem);
            documento.add(new Paragraph(new Date().toString()));
            documento.add(new Paragraph("------------------------------------COMPROVANTE DE VENDA------------------------------------"));
            documento.add(Chunk.NEWLINE);
            Paragraph AssinaturaTecnicoParagraph = new Paragraph("ID da Venda:  " + ID + "   Assinatura do Vendedor:______________________________");
            documento.add(AssinaturaTecnicoParagraph);
                     


            //adicionando um texto para o pdf
            Paragraph NomeParagraph = new Paragraph("Cliente:  " + Nome + "  Telefone:  " + Telefone);
            documento.add(NomeParagraph);
            //documento.add(Chunk.NEWLINE);
            Paragraph EnderecoParagraph = new Paragraph("Endereço:  " + Endereco + "  Nº:  " + Nº);
            documento.add(EnderecoParagraph);
            documento.add(Chunk.NEWLINE);
            Paragraph ProdutosParagraph = new Paragraph("Produto(s):  " + Produtos);
            documento.add(ProdutosParagraph);
            documento.add(Chunk.NEWLINE);
            Paragraph VendedorParagraph = new Paragraph("Vendedor: " + Vendedor + "  Data de Venda: " + DataVenda + "  Data de Pagamento: " + DataPagamento);
            documento.add(VendedorParagraph);
            //documento.add(Chunk.NEWLINE);
            Paragraph PagamentoParagraph = new Paragraph("Forma de Pagamento: " + FormaPagamento + "  Pagamento: " + Pagamento);
            documento.add(PagamentoParagraph);
            //documento.add(Chunk.NEWLINE);
            Paragraph NParcelasParagraph = new Paragraph("Nº Parcelas:  " + NParcelas + "  Nº Parcelas Pagas:  " + NParcelasPagas);
            documento.add(NParcelasParagraph);
            //documento.add(Chunk.NEWLINE);
            Paragraph CompraParagraph = new Paragraph("Valor da Parcela:  R$" + ValorParcelas + "  Total da Compra:  R$" + TotalCompra);
            documento.add(CompraParagraph);
            documento.add(new Paragraph("----------------------------------------------------------------------------------------------------------------"));
            Paragraph assinaturas = new Paragraph("COMPROVANTE DO VENDEDOR");
            assinaturas.setAlignment(Element.ALIGN_CENTER);
            documento.add(assinaturas);
            Paragraph IDParagraph = new Paragraph("ID de Venda:  " + ID + "     Data de Pagamento:  " + DataPagamento);
            documento.add(IDParagraph);
            documento.add(Chunk.NEWLINE);
            Paragraph AssinaturaClienteParagraph = new Paragraph("Cliente:___________________________________________________");
            documento.add(AssinaturaClienteParagraph);            
            documento.add(Chunk.NEWLINE);
            Paragraph AssinaturaTecnico2Paragraph = new Paragraph("Vendedor:__________________________________________________");
            documento.add(AssinaturaTecnico2Paragraph);


            documento.close();
        } catch (DocumentException ex) {
            JOptionPane.showMessageDialog(null, ex);
        } catch (FileNotFoundException ex) {
            JOptionPane.showMessageDialog(null, ex);
        }

    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

        public void Novo(){
        
            try {
                
                tf_nome.setEditable(true);                
                tf_endereco.setEditable(true);
                tf_numero.setEditable(true);
                jf_telefone.setEditable(true);
                jf_datav.setEditable(true);
                jf_datap.setEditable(true);
                tf_valorunit.setEditable(false);
                tf_quantidade.setEditable(true);               
                tf_totalproduto.setEditable(true);
                tf_cor.setEditable(true);
                jt_produtos.setEditable(true);
                tf_nparcelas.setEditable(true); 
                tf_valorparcela.setEditable(true);
                tf_parcelaspg.setEditable(true);
                tf_total.setEditable(true);
                cb_vendedor.setEnabled(true);
                cb_produto.setEnabled(true);
                cb_formapgto.setEnabled(true);
                cb_pagamento.setEnabled(true);
                jb_adicionar.setEnabled(true);
                jb_remover.setEnabled(true);
                jb_salvar.setEnabled(true);
                jt_produtos.setText("");
                
                cb_vendedor.setSelectedItem("VENDEDOR");
                jf_datav.setText("");
                jf_datap.setText("");
                tf_quantidade.setText("");
                tf_valorunit.setText("");
                tf_id.setText("");
                tf_cor.setText("");
                tf_totalproduto.setText("");
                tf_nparcelas.setText("");
                tf_parcelaspg.setText("");
                tf_valorparcela.setText("");
                tf_total.setText("");
                cb_produto.setSelectedItem("SELECIONE O PRODUTO");
                cb_formapgto.setSelectedItem("FORMA DE PAGAMENTO"); 
                
            } catch (Exception e) {
            }
        }
        
//<----------------------------------------------------------------------------------------------------------------------------------------->    

                public void Limpar(){
                                    
                tf_nome.setText("");
                tf_endereco.setText("");
                tf_numero.setText("");
                jf_telefone.setText("");
                cb_vendedor.setSelectedItem("VENDEDOR");
                jf_datav.setText("");
                jf_datap.setText("");
                tf_quantidade.setText("");
                tf_valorunit.setText("");
                tf_id.setText("");
                tf_cor.setText("");
                tf_totalproduto.setText("");
                tf_nparcelas.setText("");
                tf_parcelaspg.setText("");
                tf_valorparcela.setText("");
                tf_total.setText("");
                cb_produto.setSelectedItem("SELECIONE O PRODUTO");
                cb_formapgto.setSelectedItem("FORMA DE PAGAMENTO");
                
                }     


    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel18 = new javax.swing.JLabel();
        cb_produto = new javax.swing.JComboBox();
        jLabel16 = new javax.swing.JLabel();
        cb_pagamento = new javax.swing.JComboBox();
        tf_nome = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        tf_endereco = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        tf_numero = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jf_telefone = new javax.swing.JFormattedTextField();
        jLabel15 = new javax.swing.JLabel();
        tf_pesquisar = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jt_cliente = new javax.swing.JTable();
        tf_id = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jf_datav = new javax.swing.JFormattedTextField();
        jLabel9 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel13 = new javax.swing.JLabel();
        jb_fechar = new javax.swing.JButton();
        jb_limpar = new javax.swing.JButton();
        jb_salvar = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        tf_valorunit = new javax.swing.JTextField();
        tf_quantidade = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        tf_totalproduto = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        tf_nparcelas = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        tf_parcelaspg = new javax.swing.JTextField();
        jf_datap = new javax.swing.JFormattedTextField();
        jLabel21 = new javax.swing.JLabel();
        jb_adicionar = new javax.swing.JButton();
        jb_remover = new javax.swing.JButton();
        tf_cor = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jt_produtos = new javax.swing.JTextArea();
        jLabel23 = new javax.swing.JLabel();
        tf_total = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        tf_valorparcela = new javax.swing.JTextField();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        cb_vendedor = new javax.swing.JComboBox();
        jLabel27 = new javax.swing.JLabel();
        cb_formapgto = new javax.swing.JComboBox();
        jButton2 = new javax.swing.JButton();
        jb_novo = new javax.swing.JButton();
        jb_atualizar = new javax.swing.JButton();
        jLabel28 = new javax.swing.JLabel();
        jb_solicitar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("AssisTec - Registrar Vendas");
        setResizable(false);
        getContentPane().setLayout(null);

        jLabel18.setBackground(new java.awt.Color(255, 255, 255));
        jLabel18.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel18.setForeground(new java.awt.Color(255, 255, 255));
        jLabel18.setText("SELECIONE O PRODUTO");
        getContentPane().add(jLabel18);
        jLabel18.setBounds(10, 130, 170, 14);

        cb_produto.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        cb_produto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SELECIONE O PRODUTO" }));
        cb_produto.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        cb_produto.setEnabled(false);
        cb_produto.addPopupMenuListener(new javax.swing.event.PopupMenuListener() {
            public void popupMenuCanceled(javax.swing.event.PopupMenuEvent evt) {
            }
            public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {
                cb_produtoPopupMenuWillBecomeInvisible(evt);
            }
            public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {
            }
        });
        cb_produto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_produtoActionPerformed(evt);
            }
        });
        getContentPane().add(cb_produto);
        cb_produto.setBounds(10, 150, 580, 30);

        jLabel16.setBackground(new java.awt.Color(255, 255, 255));
        jLabel16.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel16.setForeground(new java.awt.Color(255, 255, 255));
        jLabel16.setText("PAGAMENTO");
        getContentPane().add(jLabel16);
        jLabel16.setBounds(930, 250, 90, 14);

        cb_pagamento.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        cb_pagamento.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "À VISTA", "À PRAZO" }));
        cb_pagamento.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        cb_pagamento.setEnabled(false);
        getContentPane().add(cb_pagamento);
        cb_pagamento.setBounds(930, 270, 100, 30);

        tf_nome.setEditable(false);
        tf_nome.setBackground(new java.awt.Color(255, 255, 255));
        tf_nome.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_nome.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_nome.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_nome);
        tf_nome.setBounds(10, 30, 250, 30);

        jLabel5.setBackground(new java.awt.Color(255, 255, 255));
        jLabel5.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("NOME DO CLIENTE");
        getContentPane().add(jLabel5);
        jLabel5.setBounds(10, 10, 130, 14);

        tf_endereco.setEditable(false);
        tf_endereco.setBackground(new java.awt.Color(255, 255, 255));
        tf_endereco.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_endereco.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_endereco.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_endereco);
        tf_endereco.setBounds(270, 30, 240, 30);

        jLabel14.setBackground(new java.awt.Color(255, 255, 255));
        jLabel14.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel14.setForeground(new java.awt.Color(255, 255, 255));
        jLabel14.setText("ENDEREÇO");
        getContentPane().add(jLabel14);
        jLabel14.setBounds(270, 10, 80, 14);

        tf_numero.setEditable(false);
        tf_numero.setBackground(new java.awt.Color(255, 255, 255));
        tf_numero.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_numero.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_numero.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_numero);
        tf_numero.setBounds(520, 30, 40, 30);

        jLabel17.setBackground(new java.awt.Color(255, 255, 255));
        jLabel17.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel17.setForeground(new java.awt.Color(255, 255, 255));
        jLabel17.setText("Nº");
        getContentPane().add(jLabel17);
        jLabel17.setBounds(520, 10, 40, 14);

        jf_telefone.setEditable(false);
        jf_telefone.setBackground(new java.awt.Color(255, 255, 255));
        jf_telefone.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        try {
            jf_telefone.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jf_telefone.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jf_telefone.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(jf_telefone);
        jf_telefone.setBounds(570, 30, 110, 30);

        jLabel15.setBackground(new java.awt.Color(255, 255, 255));
        jLabel15.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel15.setForeground(new java.awt.Color(255, 255, 255));
        jLabel15.setText("TELEFONE");
        getContentPane().add(jLabel15);
        jLabel15.setBounds(570, 10, 70, 14);

        tf_pesquisar.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_pesquisar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_pesquisar.setSelectionColor(new java.awt.Color(0, 0, 0));
        tf_pesquisar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tf_pesquisarActionPerformed(evt);
            }
        });
        tf_pesquisar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tf_pesquisarKeyReleased(evt);
            }
        });
        getContentPane().add(tf_pesquisar);
        tf_pesquisar.setBounds(1030, 330, 240, 30);

        jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_lupa.png"))); // NOI18N
        getContentPane().add(jLabel7);
        jLabel7.setBounds(1010, 330, 20, 30);

        jLabel8.setBackground(new java.awt.Color(255, 255, 255));
        jLabel8.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("PESQUISAR CLIENTE");
        getContentPane().add(jLabel8);
        jLabel8.setBounds(1030, 310, 200, 14);

        jt_cliente.setAutoCreateRowSorter(true);
        jt_cliente.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jt_cliente.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jt_cliente.setSelectionBackground(new java.awt.Color(0, 0, 0));
        jt_cliente.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jt_clienteMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jt_cliente);

        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(0, 370, 1280, 170);

        tf_id.setEditable(false);
        tf_id.setBackground(new java.awt.Color(255, 255, 255));
        tf_id.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_id.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_id.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_id);
        tf_id.setBounds(1060, 130, 50, 30);

        jLabel12.setBackground(new java.awt.Color(255, 255, 255));
        jLabel12.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel12.setForeground(new java.awt.Color(255, 255, 255));
        jLabel12.setText("ID");
        getContentPane().add(jLabel12);
        jLabel12.setBounds(1060, 110, 30, 20);

        jf_datav.setEditable(false);
        jf_datav.setBackground(new java.awt.Color(255, 255, 255));
        jf_datav.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        try {
            jf_datav.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jf_datav.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jf_datav.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(jf_datav);
        jf_datav.setBounds(270, 90, 100, 30);

        jLabel9.setBackground(new java.awt.Color(255, 255, 255));
        jLabel9.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(255, 255, 255));
        jLabel9.setText("DATA DE VENDA");
        getContentPane().add(jLabel9);
        jLabel9.setBounds(270, 70, 110, 14);

        jSeparator1.setForeground(new java.awt.Color(255, 255, 255));
        getContentPane().add(jSeparator1);
        jSeparator1.setBounds(70, 560, 1210, 10);

        jLabel13.setForeground(new java.awt.Color(255, 255, 255));
        jLabel13.setText("AssisTec");
        getContentPane().add(jLabel13);
        jLabel13.setBounds(10, 550, 60, 14);

        jb_fechar.setBackground(new java.awt.Color(255, 255, 255));
        jb_fechar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_fechar.png"))); // NOI18N
        jb_fechar.setText("FECHAR");
        jb_fechar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_fechar.setBorderPainted(false);
        jb_fechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_fecharActionPerformed(evt);
            }
        });
        getContentPane().add(jb_fechar);
        jb_fechar.setBounds(1170, 570, 100, 50);

        jb_limpar.setBackground(new java.awt.Color(255, 255, 255));
        jb_limpar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_limpar.png"))); // NOI18N
        jb_limpar.setText("LIMPAR");
        jb_limpar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_limpar.setBorderPainted(false);
        jb_limpar.setEnabled(false);
        jb_limpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_limparActionPerformed(evt);
            }
        });
        getContentPane().add(jb_limpar);
        jb_limpar.setBounds(1070, 570, 100, 50);

        jb_salvar.setBackground(new java.awt.Color(255, 255, 255));
        jb_salvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_salvar.png"))); // NOI18N
        jb_salvar.setText("SALVAR");
        jb_salvar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_salvar.setBorderPainted(false);
        jb_salvar.setEnabled(false);
        jb_salvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_salvarActionPerformed(evt);
            }
        });
        getContentPane().add(jb_salvar);
        jb_salvar.setBounds(970, 570, 100, 50);

        jLabel4.setBackground(new java.awt.Color(255, 255, 255));
        jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("NOME DO VENDEDOR");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(10, 70, 140, 14);

        jLabel11.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel11.setForeground(new java.awt.Color(255, 255, 255));
        jLabel11.setText("REGISTRAR VENDAS");
        getContentPane().add(jLabel11);
        jLabel11.setBounds(1140, 170, 120, 14);

        jLabel10.setBackground(new java.awt.Color(255, 255, 255));
        jLabel10.setForeground(new java.awt.Color(78, 78, 78));
        jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_vendas.png"))); // NOI18N
        jLabel10.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        getContentPane().add(jLabel10);
        jLabel10.setBounds(1120, 10, 150, 150);

        tf_valorunit.setEditable(false);
        tf_valorunit.setBackground(new java.awt.Color(255, 255, 255));
        tf_valorunit.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_valorunit.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_valorunit.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_valorunit);
        tf_valorunit.setBounds(600, 90, 80, 30);

        tf_quantidade.setEditable(false);
        tf_quantidade.setBackground(new java.awt.Color(255, 255, 255));
        tf_quantidade.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_quantidade.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_quantidade.setSelectionColor(new java.awt.Color(0, 0, 0));
        tf_quantidade.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tf_quantidadeFocusLost(evt);
            }
        });
        tf_quantidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tf_quantidadeActionPerformed(evt);
            }
        });
        getContentPane().add(tf_quantidade);
        tf_quantidade.setBounds(690, 90, 80, 30);

        jLabel6.setBackground(new java.awt.Color(255, 255, 255));
        jLabel6.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("QUANTIDADE");
        getContentPane().add(jLabel6);
        jLabel6.setBounds(690, 70, 80, 14);

        jLabel3.setBackground(new java.awt.Color(255, 255, 255));
        jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("VALOR UNIT.");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(600, 70, 80, 14);

        jButton1.setBackground(new java.awt.Color(255, 255, 255));
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_calculadora.png"))); // NOI18N
        jButton1.setText("CALCULADORA");
        jButton1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jButton1.setBorderPainted(false);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1);
        jButton1.setBounds(990, 10, 120, 50);

        jLabel2.setBackground(new java.awt.Color(255, 255, 255));
        jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("TOTAL R$ PRODUTO");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(780, 70, 130, 14);

        tf_totalproduto.setEditable(false);
        tf_totalproduto.setBackground(new java.awt.Color(255, 255, 255));
        tf_totalproduto.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_totalproduto.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_totalproduto.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_totalproduto);
        tf_totalproduto.setBounds(780, 90, 90, 30);

        jLabel19.setBackground(new java.awt.Color(255, 255, 255));
        jLabel19.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel19.setForeground(new java.awt.Color(255, 255, 255));
        jLabel19.setText("Nº PARCELAS");
        getContentPane().add(jLabel19);
        jLabel19.setBounds(600, 190, 80, 14);

        tf_nparcelas.setEditable(false);
        tf_nparcelas.setBackground(new java.awt.Color(255, 255, 255));
        tf_nparcelas.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_nparcelas.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_nparcelas.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_nparcelas);
        tf_nparcelas.setBounds(600, 210, 80, 30);

        jLabel20.setBackground(new java.awt.Color(255, 255, 255));
        jLabel20.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel20.setForeground(new java.awt.Color(255, 255, 255));
        jLabel20.setText("Nº PARC. PAGAS");
        getContentPane().add(jLabel20);
        jLabel20.setBounds(600, 250, 100, 14);

        tf_parcelaspg.setEditable(false);
        tf_parcelaspg.setBackground(new java.awt.Color(255, 255, 255));
        tf_parcelaspg.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_parcelaspg.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_parcelaspg.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_parcelaspg);
        tf_parcelaspg.setBounds(600, 270, 90, 30);

        jf_datap.setEditable(false);
        jf_datap.setBackground(new java.awt.Color(255, 255, 255));
        jf_datap.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        try {
            jf_datap.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jf_datap.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jf_datap.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(jf_datap);
        jf_datap.setBounds(380, 90, 100, 30);

        jLabel21.setBackground(new java.awt.Color(255, 255, 255));
        jLabel21.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel21.setForeground(new java.awt.Color(255, 255, 255));
        jLabel21.setText("DATA DE PAGTO.");
        getContentPane().add(jLabel21);
        jLabel21.setBounds(380, 70, 100, 14);

        jb_adicionar.setBackground(new java.awt.Color(255, 255, 255));
        jb_adicionar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_adicionar.png"))); // NOI18N
        jb_adicionar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jb_adicionar.setBorderPainted(false);
        jb_adicionar.setEnabled(false);
        jb_adicionar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_adicionarActionPerformed(evt);
            }
        });
        getContentPane().add(jb_adicionar);
        jb_adicionar.setBounds(780, 150, 63, 30);

        jb_remover.setBackground(new java.awt.Color(255, 255, 255));
        jb_remover.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_remover.png"))); // NOI18N
        jb_remover.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jb_remover.setBorderPainted(false);
        jb_remover.setEnabled(false);
        jb_remover.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_removerActionPerformed(evt);
            }
        });
        getContentPane().add(jb_remover);
        jb_remover.setBounds(890, 150, 63, 30);

        tf_cor.setEditable(false);
        tf_cor.setBackground(new java.awt.Color(255, 255, 255));
        tf_cor.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_cor.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_cor.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_cor);
        tf_cor.setBounds(600, 150, 170, 30);

        jLabel22.setBackground(new java.awt.Color(255, 255, 255));
        jLabel22.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel22.setForeground(new java.awt.Color(255, 255, 255));
        jLabel22.setText("COR");
        getContentPane().add(jLabel22);
        jLabel22.setBounds(600, 130, 27, 14);

        jt_produtos.setEditable(false);
        jt_produtos.setColumns(20);
        jt_produtos.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jt_produtos.setRows(5);
        jt_produtos.setSelectionColor(new java.awt.Color(0, 0, 0));
        jScrollPane3.setViewportView(jt_produtos);

        getContentPane().add(jScrollPane3);
        jScrollPane3.setBounds(10, 190, 580, 170);

        jLabel23.setBackground(new java.awt.Color(255, 255, 255));
        jLabel23.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel23.setForeground(new java.awt.Color(255, 255, 255));
        jLabel23.setText("TOTAL R$ COMPRA");
        getContentPane().add(jLabel23);
        jLabel23.setBounds(600, 310, 120, 14);

        tf_total.setEditable(false);
        tf_total.setBackground(new java.awt.Color(255, 255, 255));
        tf_total.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_total.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_total.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_total);
        tf_total.setBounds(600, 330, 110, 30);

        jLabel24.setBackground(new java.awt.Color(255, 255, 255));
        jLabel24.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel24.setForeground(new java.awt.Color(255, 255, 255));
        jLabel24.setText("VALOR R$ PARCELA");
        getContentPane().add(jLabel24);
        jLabel24.setBounds(690, 190, 120, 14);

        tf_valorparcela.setEditable(false);
        tf_valorparcela.setBackground(new java.awt.Color(255, 255, 255));
        tf_valorparcela.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_valorparcela.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_valorparcela.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_valorparcela);
        tf_valorparcela.setBounds(690, 210, 100, 30);

        jLabel25.setBackground(new java.awt.Color(255, 255, 255));
        jLabel25.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel25.setForeground(new java.awt.Color(255, 255, 255));
        jLabel25.setText("ADICIONAR");
        getContentPane().add(jLabel25);
        jLabel25.setBounds(780, 130, 70, 14);

        jLabel26.setBackground(new java.awt.Color(255, 255, 255));
        jLabel26.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel26.setForeground(new java.awt.Color(255, 255, 255));
        jLabel26.setText("LIMPAR");
        getContentPane().add(jLabel26);
        jLabel26.setBounds(900, 130, 50, 14);

        cb_vendedor.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        cb_vendedor.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "VENDEDOR" }));
        cb_vendedor.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        cb_vendedor.setEnabled(false);
        getContentPane().add(cb_vendedor);
        cb_vendedor.setBounds(10, 90, 250, 30);

        jLabel27.setBackground(new java.awt.Color(255, 255, 255));
        jLabel27.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel27.setForeground(new java.awt.Color(255, 255, 255));
        jLabel27.setText("FORMA DE PAGAMENTO");
        getContentPane().add(jLabel27);
        jLabel27.setBounds(700, 250, 160, 14);

        cb_formapgto.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        cb_formapgto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "FORMA DE PAGAMENTO", "DINHEIRO", "CARTÃO DE CRÉDITO", "CHEQUE", "DEPÓSITO BANCÁRIO", "TRANSFERÊNCIA BANCÁRIA" }));
        cb_formapgto.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        cb_formapgto.setEnabled(false);
        getContentPane().add(cb_formapgto);
        cb_formapgto.setBounds(700, 270, 220, 30);

        jButton2.setBackground(new java.awt.Color(255, 255, 255));
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_pdf.gif"))); // NOI18N
        jButton2.setText("GERAR PDF");
        jButton2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jButton2.setBorderPainted(false);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton2);
        jButton2.setBounds(890, 10, 100, 50);

        jb_novo.setBackground(new java.awt.Color(255, 255, 255));
        jb_novo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_novo.png"))); // NOI18N
        jb_novo.setText("NOVO");
        jb_novo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jb_novo.setBorderPainted(false);
        jb_novo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_novoActionPerformed(evt);
            }
        });
        getContentPane().add(jb_novo);
        jb_novo.setBounds(10, 570, 100, 50);

        jb_atualizar.setBackground(new java.awt.Color(255, 255, 255));
        jb_atualizar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_atualizar.png"))); // NOI18N
        jb_atualizar.setText("ATUALIZAR");
        jb_atualizar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jb_atualizar.setBorderPainted(false);
        jb_atualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_atualizarActionPerformed(evt);
            }
        });
        getContentPane().add(jb_atualizar);
        jb_atualizar.setBounds(110, 570, 100, 50);

        jLabel28.setBackground(new java.awt.Color(255, 255, 255));
        jLabel28.setForeground(new java.awt.Color(255, 255, 255));
        jLabel28.setText("TABELA DE CLIENTES");
        getContentPane().add(jLabel28);
        jLabel28.setBounds(570, 540, 130, 20);

        jb_solicitar.setBackground(new java.awt.Color(255, 255, 255));
        jb_solicitar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_solicitar.png"))); // NOI18N
        jb_solicitar.setText("SOLICITAR");
        jb_solicitar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jb_solicitar.setBorderPainted(false);
        jb_solicitar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_solicitarActionPerformed(evt);
            }
        });
        getContentPane().add(jb_solicitar);
        jb_solicitar.setBounds(570, 570, 120, 50);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_fundo2.png"))); // NOI18N
        getContentPane().add(jLabel1);
        jLabel1.setBounds(0, 0, 1280, 650);

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void jb_fecharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_fecharActionPerformed
        dispose();
    }//GEN-LAST:event_jb_fecharActionPerformed

    private void jb_limparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_limparActionPerformed
                Limpar();
    }//GEN-LAST:event_jb_limparActionPerformed

    private void tf_pesquisarKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tf_pesquisarKeyReleased
        pesquisarCliente();
    }//GEN-LAST:event_tf_pesquisarKeyReleased

    private void jt_clienteMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jt_clienteMouseClicked
        try {
            mostraItens();
            jb_limpar.setEnabled(true);
            jb_salvar.setEnabled(false);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Tela_RegVendas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jt_clienteMouseClicked

    private void jb_salvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_salvarActionPerformed
        registrarVenda();
    }//GEN-LAST:event_jb_salvarActionPerformed

    private void tf_pesquisarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_pesquisarActionPerformed

    }//GEN-LAST:event_tf_pesquisarActionPerformed

    private void cb_produtoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_produtoActionPerformed

    }//GEN-LAST:event_cb_produtoActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
                Tela_Calc tc = new Tela_Calc();
                tc.setVisible(true);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void cb_produtoPopupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_cb_produtoPopupMenuWillBecomeInvisible
                String ps = (String)cb_produto.getSelectedItem();
                String sql = "Select * from produto where Produto_Serviço = ?";
                try {
                    
                    pst = conecta.prepareCall(sql);
                    pst.setString(1, ps);
                    rs = pst.executeQuery();
                    if(rs.next()){
                    String valor = rs.getString("Preço");
                    tf_valorunit.setText(valor);
                    String cor = rs.getString("Cor");
                    tf_cor.setText(cor);
                    }
                    
                } catch (Exception e) {
                }
    }//GEN-LAST:event_cb_produtoPopupMenuWillBecomeInvisible

    private void jb_adicionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_adicionarActionPerformed
                String produto = cb_produto.getSelectedItem()+"  Cor: "+tf_cor.getText()+"  Quantidade: "+tf_quantidade.getText()+"  Unidade.R$:"+tf_valorunit.getText()+"  Total.R$:"+tf_totalproduto.getText();
                
                if(tf_quantidade.getText().equals("")){
                JOptionPane.showMessageDialog(null, "Campo Quantidade é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
                return;
                }
                if(tf_totalproduto.getText().equals("")){
                JOptionPane.showMessageDialog(null, "Campo Total produto é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
                return;
                }
                if(cb_produto.getSelectedItem().equals("SELECIONE O PRODUTO")){
                JOptionPane.showMessageDialog(null, "Selecione um produto", "Aviso", JOptionPane.WARNING_MESSAGE);
                return;
                }
                
                
                jt_produtos.append(produto +"\n");
    }//GEN-LAST:event_jb_adicionarActionPerformed

    private void jb_removerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_removerActionPerformed
                jt_produtos.setText("");
    }//GEN-LAST:event_jb_removerActionPerformed

    private void tf_quantidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_quantidadeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tf_quantidadeActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

        if (Desktop.isDesktopSupported()) {
            try {
                PDF(tf_id.getText(), tf_nome.getText(), tf_endereco.getText(), tf_numero.getText(), jf_telefone.getText(), cb_vendedor.getSelectedItem().toString(), jf_datav.getText(), jf_datap.getText(), jt_produtos.getText(), tf_nparcelas.getText(), tf_valorparcela.getText(), tf_parcelaspg.getText(), cb_formapgto.getSelectedItem().toString(), cb_pagamento.getSelectedItem().toString(), tf_total.getText());
                File myFile = new File("venda.pdf");
                Desktop.getDesktop().open(myFile);
            } catch (IOException ex) {
            }   catch (BadElementException ex) {
                Logger.getLogger(Tela_GerVendas.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jb_novoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_novoActionPerformed
        Novo();
        jb_limpar.setEnabled(true);
    }//GEN-LAST:event_jb_novoActionPerformed

    private void jb_atualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_atualizarActionPerformed
        listarCliente();
    }//GEN-LAST:event_jb_atualizarActionPerformed

    private void tf_quantidadeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tf_quantidadeFocusLost

    }//GEN-LAST:event_tf_quantidadeFocusLost

    private void jb_solicitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_solicitarActionPerformed
        Tela_RegSolicitacao trs = null;
        try {
            trs = new Tela_RegSolicitacao();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Tela_OrcamentoBasico.class.getName()).log(Level.SEVERE, null, ex);
        }
        trs.setVisible(true);
    }//GEN-LAST:event_jb_solicitarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Tela_RegVendas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Tela_RegVendas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Tela_RegVendas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Tela_RegVendas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new Tela_RegVendas().setVisible(true);
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(Tela_RegVendas.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cb_formapgto;
    private javax.swing.JComboBox cb_pagamento;
    private javax.swing.JComboBox cb_produto;
    private javax.swing.JComboBox cb_vendedor;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JButton jb_adicionar;
    private javax.swing.JButton jb_atualizar;
    private javax.swing.JButton jb_fechar;
    private javax.swing.JButton jb_limpar;
    private javax.swing.JButton jb_novo;
    private javax.swing.JButton jb_remover;
    private javax.swing.JButton jb_salvar;
    private javax.swing.JButton jb_solicitar;
    private javax.swing.JFormattedTextField jf_datap;
    private javax.swing.JFormattedTextField jf_datav;
    private javax.swing.JFormattedTextField jf_telefone;
    private javax.swing.JTable jt_cliente;
    private javax.swing.JTextArea jt_produtos;
    private javax.swing.JTextField tf_cor;
    private javax.swing.JTextField tf_endereco;
    private javax.swing.JTextField tf_id;
    private javax.swing.JTextField tf_nome;
    private javax.swing.JTextField tf_nparcelas;
    private javax.swing.JTextField tf_numero;
    private javax.swing.JTextField tf_parcelaspg;
    private javax.swing.JTextField tf_pesquisar;
    private javax.swing.JTextField tf_quantidade;
    private javax.swing.JTextField tf_total;
    private javax.swing.JTextField tf_totalproduto;
    private javax.swing.JTextField tf_valorparcela;
    private javax.swing.JTextField tf_valorunit;
    // End of variables declaration//GEN-END:variables
}
